using Assets.Scripts.GDK;
using UnityEngine;

namespace Brick
{
	public class BottomIronBox : gdk_base_UI
	{
		public override void OnLoad()
		{
			gdk_game_manager.AddEventListener(EventID.GAME_SHOOP_START, setCanShoting);
			gdk_game_manager.AddEventListener(EventID.DOWNMENUE_ADDIRON5, onAddIron);
		}

		public override void UnLoad()
		{
			gdk_game_manager.RemoveEventListener(EventID.GAME_SHOOP_START, setCanShoting);
			gdk_game_manager.RemoveEventListener(EventID.DOWNMENUE_ADDIRON5, onAddIron);
		}

		private void onAddIron()
		{
			Vector2 shootPos = GDK.ModuleManger.Module<BallFindWayModule>().getShootPos();
			bool flag = true;
			if (shootPos.x < 0f)
			{
				flag = false;
			}
			for (int i = 0; i < 5; i++)
			{
				string id = "Prefabs/Type" + 2 + "/type_" + 2 + "_" + 4;
				GameObject gameObject = gdk_game_manager.loadPrefab(id);
				gameObject.transform.SetParent(base.gameObject.transform);
				gameObject.transform.localScale = Vector3.one;
				if (flag)
				{
					gameObject.transform.localPosition = new Vector3(-360 + i * 61 + 31, 31f, 0f);
				}
				else
				{
					gameObject.transform.localPosition = new Vector3(360 - i * 61 - 31, 31f, 0f);
				}
			}
		}

		private void setCanShoting()
		{
			int childCount = base.transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				UnityEngine.Object.Destroy(base.transform.GetChild(i).gameObject);
			}
		}
	}

}

